package com.sky.controller.admin;

import com.sky.constant.RedisConstant;
import com.sky.result.Result;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * ClassName: ShopController
 * Package: com.sky.controller.admin
 * Description:店铺状态
 *
 * @Author: Zhang Peiyuan
 * @Create: 2024-12-20-19:22
 * @Version: v1.0
 */
@RestController("adminShopController")
@RequestMapping("/admin/shop")
public class ShopController {
    @Resource
    private StringRedisTemplate rds;

    /**
     * 更新店铺状态
     * @param status
     */
    @PutMapping("/{status}")
    public Result updateStatus(@PathVariable Integer status) {
        rds.opsForValue().set(RedisConstant.SHOP_STATUS, status.toString());
        return Result.success();
    }

    /**
     * 查询店铺状态
     */
    @GetMapping("/status")
    public Result<Integer> queryStatus(){
        String status = rds.opsForValue().get(RedisConstant.SHOP_STATUS);
        return Result.success(Integer.parseInt(status));
    }
}
